import { ref, watch } from 'vue'

export let record = ref()
try {
  let recordStorage = localStorage.getItem('record')
  if (recordStorage) {
    record.value = JSON.parse(recordStorage)
  } else {
    record.value = {}
  }
} catch (error) {
  record.value = {}
}

watch(
  record,
  (newValue) => {
    localStorage.setItem('record', JSON.stringify(newValue))
  },
  {
    deep: true
  }
)
